﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Pheonix.Fashionzoomer.BLL;
using Pheonix.CodeLibrary;
using Pheonix.Fashionzoomer.Entity.SqlServer2000;
using Pheonix.CodeLibrary.Web;

public partial class page_private_user_ReadReplyMessagePage : AdminBasePage
{
    Message DisplyedMgs;
    protected void Page_Load(object sender, EventArgs e)
    {
        
        Title = SiteName + " - Message Reply";
        try
         {
          //SiteConfigSection config = SiteConfigSection.SiteConfiguration;
          //string userEmail = Utility.Decrypt(Request.Params["senderemail"].ToString(), config.SecurityKey, true);
          //int messangeid = Int32.Parse(Utility.Decrypt(Request.Params["messangeid"].ToString(),config.SecurityKey, true));

          DisplyedMgs = MessageManager.GetMsgByMsgId(Int32.Parse(Request.Params["messangeid"].ToString()));
          DisplyedMgs.IsRead = true;
          DisplyedMgs.Save();  
          lblsender.Text = Request.Params["senderemail"].ToString();
          lblTimeStamp.Text = DisplyedMgs.WhenSent.ToString();
          LtrlMessageBody.Text= DisplyedMgs.MessageBody.ToString();
          
        }
        catch
        {
            LtrlMessageBody.Text = "The System cannot read the mail. Sorry for inconvinence";
        }
    }
    protected void ButtonSend_Click(object sender, EventArgs e)
    {
        Message newMessage = new Message();
        newMessage.IsRead = false;
        newMessage.ParentMessageId = DisplyedMgs.Id;
        newMessage.ReceiverUserId=DisplyedMgs.SenderUserId;
        newMessage.SenderUserId=DisplyedMgs.ReceiverUserId;
        newMessage.MessageBody =txtMsgBody.Text;
        newMessage.WhenSent = System.DateTime.Now;
        newMessage.Save();
    }
}
